<template>
  <!-- 岗位等级 -->
  <view>
    <u-line color="#EEEEF5" class="line" />
    <view class="styleJobDescriptionContainer">
      <view class="styleJobDescriptionTitleContainer">
        <view class="styleJobDescriptionTitleLine"></view>
        <view class="styleJobDescriptionTitle"> {{ layerInfo.title }}</view>
      </view>
      <view class="content" v-if="layerInfo.data && layerInfo.data.length > 0">
        <LevelSalaryChart
          :salaryWorkYearChart="salaryWorkYearChart"
        ></LevelSalaryChart>
      </view>
      <Empty
        v-else
        :baseImg="emptyImg"
        :text="emptyTitle"
        :fontWeight="400"
        textColor="#bfbfbf"
        class="empty"
        spacing="0"
      />
    </view>
  </view>
</template>
<script>
import Empty from '@/components/Empty.vue';
import LoginDialog from '@/components/LoginDialog';
import LevelSalaryChart from './charts/levelSalaryChart';

export default {
  components: {
    LevelSalaryChart,
    Empty,
    LoginDialog
  },
  props: {
    layerInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      loading: false,
      salaryWorkYearChart: {}, //等级薪酬图表数据
      emptyTitle: '暂无数据'
    };
  },
  created() {},
  mounted() {
    this.handleLayerInfo();
  },
  watch: {
    layerInfo: {
      handler(val) {
        console.log(val, '==============================');

        if (val.data && val.data.length > 0) {
          this.$nextTick(() => {
            this.handleLayerInfo();
          });
        }
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    getWidth(length) {
      return `${(100 / length).toFixed(2)}%`;
    },
    handleLayerInfo() {
      const jsonList = this.layerInfo.data;
      let result = {
        dataX: [],
        dataY: []
      };
      jsonList.forEach((item, index) => {
        if (index < 4) {
          if (item.expCodeStr == '应届生') {
            item.expCodeStr = '入门';
          }
          if (item.expCodeStr == '0-1年') {
            item.expCodeStr = '初级';
          }
          if (item.expCodeStr == '1-3年') {
            item.expCodeStr = '中级';
          }
          if (item.expCodeStr == '3-5年') {
            item.expCodeStr = '高级';
          }
          result.dataX.push(item.expCodeStr);
          result.dataY.push(Math.floor(item.salaryNum));
        }
      });
      this.salaryWorkYearChart = result;
    }
  }
};
</script>
<style lang="scss" scoped>
.line {
  width: calc(100% - 40rpx);
  margin: 64rpx 20rpx;
}
.styleJobDescriptionContainer {
  background-color: white;
  border-radius: 16rpx;
  .styleJobDescriptionTitleContainer {
    display: flex;
    flex-direction: row;
    align-items: center;
    .styleJobDescriptionTitleLine {
      display: none;
      width: 8rpx;
      height: 36rpx;
      border-radius: 64rpx;
      background-color: #f75a3e;
      margin-right: 16rpx;
    }

    .styleJobDescriptionTitle {
      margin-left: 20rpx;
      color: #222222;
      font-size: 30rpx;
      font-weight: 800;
    }
  }
  .content {
    width: 100%;
    padding: 0rpx 0rpx;
    border-radius: 8px;
    .content-item1 {
      display: flex;
      justify-content: space-between;
      align-items: flex-end; /* 可选：整体底部对齐（若子项高度不一致） */
      padding-top: 20rpx;
      .content-item1-item {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        height: 100%; /* 假设父容器有固定高度 */
        .content-item1-title {
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 24rpx;
          color: #999999;
          line-height: 36rpx;
          text-align: center;
          font-style: normal;
        }
        .content-item1-content {
          text-align: center;
          font-family: PingFang-SC, PingFang-SC;
          font-weight: bold;
          font-size: 26rpx;
          color: #555555;
          line-height: 36rpx;
          text-align: center;
          font-style: normal;
          margin: 10rpx 10rpx;
        }
        .content-item1-icon {
          width: 100%;
          height: 192rpx;
          background: linear-gradient(180deg, #589bfd 0%, #bbdeff 100%);
          box-shadow: -2px -2px 4px -3px #418bf2;
          border-radius: 3px 3px 0px 0px;
        }
        .content-item1-icon-0 {
          width: 100%;
          height: 14rpx;
          background: linear-gradient(180deg, #589bfd 0%, #bbdeff 100%);
          border-radius: 3px 0px 0px 0px;
        }
        .content-item1-icon-1 {
          width: 100%;
          height: 52rpx;
          background: linear-gradient(180deg, #589bfd 0%, #bbdeff 100%);
          border-radius: 3px 0px 0px 0px;
        }
        .content-item1-icon-2 {
          width: 100%;
          height: 102rpx;
          background: linear-gradient(180deg, #589bfd 0%, #bbdeff 100%);
          box-shadow: -2px -2px 4px -3px #418bf2;
          border-radius: 3px 0px 0px 0px;
        }
        .content-item1-icon-3 {
          width: 100%;
          height: 192rpx;
          background: linear-gradient(180deg, #589bfd 0%, #bbdeff 100%);
          box-shadow: -2px -2px 4px -3px #418bf2;
          border-radius: 3px 3px 0px 0px;
        }
      }
    }
    .content-item2 {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin: 20rpx 6rpx;
      border-bottom: 1px solid #e8e8e8; /* 虚线、颜色、粗细 */
      padding-bottom: 5px; /* 调整下划线与文字的间距 */
      .content-item2-content {
        align-items: center;
        .content-item2-content-item {
          align-items: center;
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 24rpx;
          color: #333333;
          line-height: 28rpx;
          height: 28rpx;
          text-align: right;
          font-style: normal;
        }
        .content-item2-title {
          width: 50rpx;
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 24rpx;
          color: #999999;
          line-height: 32rpx;
          text-align: right;
          font-style: normal;
        }
      }
      .content-item2-content-two {
        display: flex;
        justify-content: space-between;
      }
    }
    .content-item2-bottom {
      padding-bottom: 20rpx;
      border-bottom: 1px solid transparent; /* 虚线、颜色、粗细 */
    }
  }
}
</style>
